package com.sws.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sws.mapping.ActivityMapper;
import com.sws.model.ActivityModel;
import com.sws.model.bean.C2SPageBean;
import com.sws.model.bean.S2CActivityBean;
import com.sws.service.ActivityService;

@Service
public class ActivityServiceImpl implements ActivityService {
	
	@Autowired
	private ActivityMapper mapper;

	@Override
	public void uploadCommonActivity(List<ActivityModel> list) {
		// TODO Auto-generated method stub
		for (ActivityModel model : list) {
			mapper.uploadActivity(model);
		}
	}

	@Override
	public List<S2CActivityBean> getPersonalActivity(C2SPageBean pageBean) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<>();
		map.put("user", pageBean.getUser());
		map.put("skips", (pageBean.getPages()-1)*pageBean.getLimits());
		map.put("limits", pageBean.getLimits());
		return mapper.getPersonalActivity(map);
	}

	@Override
	public void uploadCommonActivity(ActivityModel model) {
		// TODO Auto-generated method stub
		mapper.uploadActivity(model);
	}

}
